from selenium import webdriver
import time
path = "chromedriver.exe"
url = "https://www.baidu.com"

browse = webdriver.Chrome(path)
browse.get(url)
time.sleep(2)

# 获取文本框对象
input = browse.find_element_by_id('kw')
# 在文本框中输入信息
input.send_keys("千与千寻")
time.sleep(2)
# 获取百度一下按钮
btn = browse.find_element_by_id('su')
# 点击
btn.click()
time.sleep(2)
# 滑到底部
js_bottom = 'document.documentElement.scrollTop=10000'
browse.execute_script(js_bottom)
time.sleep(2)
# 获取下一页按钮对象
nextPage = browse.find_element_by_xpath('//a[@class="n"]')
nextPage.click()
time.sleep(2)
# 回到上一页
browse.back()
time.sleep(2)
# 回去
browse.forward()
time.sleep(2)
# 退出
browse.quit()